//
//  TraveMainDetailCell.m
//  课余时间
//
//  Created by zgr on 16/4/9.
//  Copyright © 2016年 张大少. All rights reserved.
//

#import "TraveMainDetailCell.h"
#import "UIView+SDAutoLayout.h"
#import "UIImageView+WebCache.h"
#define ORIGENY (KWIDTH -10) * 540 / 900 + 5
#define SPACEX ((KWIDTH -10) - 120)/5
@implementation TraveMainDetailCell


-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        UIView *backView = [[UIView alloc]initWithFrame:CGRectMake(5, 5, KWIDTH - 10, ((KWIDTH -10) * 540 / 900) + 50)];
     
        [self.contentView addSubview:backView];
        
        _img_url = [[UIImageView alloc]init];
        _img_url.sd_layout
        .leftSpaceToView(backView,2)
        .widthIs(KWIDTH - 10)
        .topEqualToView(backView)
        .heightIs((KWIDTH -10) * 540 / 900);
        [backView addSubview:_img_url];
        _name = [[UILabel alloc]initWithFrame:CGRectMake(10, 10, KWIDTH - 20, 60)];
        _name.numberOfLines = 2;
        _name.textColor = [UIColor whiteColor];
        [backView addSubview:_name];
        
        
        
        NSArray *titleArray = @[@"攻略",@"行程",@"景点",@"专题"];
        for (int i = 0; i< 4; i++) {
            UILabel *title = [[UILabel alloc]initWithFrame:CGRectMake(SPACEX * (i+1) + 30 * i, ORIGENY + 30, 50, 20)];
            title.text = titleArray[i];
            [backView addSubview:title];
        }
        _strategy = [UIButton buttonWithType:UIButtonTypeSystem];
        _strategy.frame = CGRectMake(SPACEX, ORIGENY, 30, 30);
       // _strategy.imageEdgeInsets = UIEdgeInsetsMake(0, 0, 0, 0);
       [ _strategy setBackgroundImage:[UIImage imageNamed:@"002.png"] forState: UIControlStateNormal ];
        
       // [_strategy setTitle:@"攻略" forState:UIControlStateNormal];
        [backView addSubview:_strategy];
        _route = [UIButton buttonWithType:UIButtonTypeSystem];
        _route.frame = CGRectMake(SPACEX * 2 + 30, ORIGENY, 30, 30);
             [ _route setBackgroundImage:[UIImage imageNamed:@"003.png"] forState: UIControlStateNormal ];
        // [_strategy setTitle:@"攻略" forState:UIControlStateNormal];
        [backView addSubview:_route];
        _sinotour = [UIButton buttonWithType:UIButtonTypeSystem];
        _sinotour.frame = CGRectMake(SPACEX * 3 + 60, ORIGENY, 30, 30);
        [ _sinotour setBackgroundImage:[UIImage imageNamed:@"001.png"] forState: UIControlStateNormal ];
        // [_strategy setTitle:@"攻略" forState:UIControlStateNormal];
        [backView addSubview:_sinotour];
        _special = [UIButton buttonWithType:UIButtonTypeSystem];
        _special.frame = CGRectMake(SPACEX * 4 + 90, ORIGENY, 30, 30);
        [ _special setBackgroundImage:[UIImage imageNamed:@"004.png"] forState: UIControlStateNormal ];
        // [_strategy setTitle:@"攻略" forState:UIControlStateNormal];
        [backView addSubview:_special];
        
        
    }
    return self;
}
-(void)setModel:(TraveMainModel *)model
{
    [_img_url sd_setImageWithURL:[NSURL URLWithString:model.image_url]];
    _name.text = [NSString stringWithFormat:@"%@ %@",model.name_zh_cn,model.name_en];
}


- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
